Dropdown List Handling

Redirect to Another Page when Dropdown Field Changes

Description
This example shows how to redirect to another page when dropdown field changes. If a user selects the dropdown list, the web application can redirect the user to a specific web page.
Variables
Record Control
Select record control class in which the dropdown list control is present
Dropdown List Control
Select the dropdown list control
Applies to
RecordControl class
Code
 
''' 
''' Overrides Protected Overridable Sub ${Dropdown List Control}_SelectedIndexChanged
''' to redirect to another page.
''' 
Protected Overrides Sub ${Dropdown List Control}_SelectedIndexChanged(ByVal sender As Object, ByVal args As EventArgs)
    
    ' retrieve the selected value of dropdown list control.
    Dim selectedValue As String 
    selectedValue = Me.${Dropdown List Control}.SelectedItem.Text

     ' Add custom code to check for the value. Here is an example of a select statement for multiple redirects when certain 
     ' values are selected for the dropdown list
     Select Case selectedValue
		' Here replace value1, value2 with actual values
        Case "value1"
              Me.Page.Response.Redirect("../OtherPages/SomeOtherPage1.aspx")
              
        Case "value2"
              Me.Page.Response.Redirect("../OtherPages/SomeOtherPage2.aspx")
    
        Case Else
	      	  Me.Page.Response.Redirect("../OtherPages/SomeOtherDefaultPage.aspx")
      
     End Select    

End Sub


''' 
''' This method sub sets up a event handler for a index changed event.
''' 
Private Sub ${Record Control}_Load(ByVal sender As Object, _
    ByVal e As System.EventArgs) Handles MyBase.Load

    Me.${Dropdown List Control}.AutoPostBack = True
    AddHandler ${Dropdown List Control}.SelectedIndexChanged, AddressOf Me.${Dropdown List Control}_SelectedIndexChanged
   
End Sub

     

Terms of Service Privacy Statement